package com.example.xinlijiankangsys.mapper;

import com.example.xinlijiankangsys.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.web.bind.annotation.RequestParam;

@Mapper
public interface UserMapper {
    @Select("select user_id as userId ,password,auth from xinlijiankang.user_tb where user_id=#{userId} and password=#{password}")
    public User selectUserByUserIdAndPassword(@RequestParam String userId, @RequestParam String password);

    @Insert("insert into xinlijiankang.user_tb (user_id, password, auth) VALUES (#{userId},#{password},#{auth})")
    public int insertUser(@RequestParam User user);

    // 新增方法：仅根据userId查询用户是否存在
    @Select("SELECT COUNT(*) FROM xinlijiankang.user_tb WHERE user_id = #{userId}")
    int countUserByUserId(@Param("userId") String userId);


}
